package cn.rongdao.jrkabao.ui.message.uicomponent;

import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.mifengkong.frtools.util.FRImageLoad;
import com.mifengkong.frtools.util.FRString;

import cn.rongdao.jrkabao.R;
import cn.rongdao.jrkabao.bean.message.SystemMessageBean;

/**
 * Created by jack on 2017/8/21
 */

public class SystemMessageUIComponent extends LinearLayout {
    public SystemMessageUIComponent(Context context) {
        super(context);
    }

    public SystemMessageUIComponent(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public SystemMessageUIComponent(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    private TextView tvHeadTime;
    private TextView tvTitle;
    private TextView tvTime;
    private ImageView ivImage;
    private TextView tvContent;

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        tvHeadTime = (TextView) findViewById(R.id.ism_tv_head_time);
        tvTitle = (TextView) findViewById(R.id.ism_tv_title);
        tvTime = (TextView) findViewById(R.id.ism_tv_time);
        ivImage = (ImageView) findViewById(R.id.ism_iv_image);
        tvContent = (TextView) findViewById(R.id.ism_tv_content);
    }

    public void setContent(SystemMessageBean data) {
        setVisibility(View.VISIBLE);
        tvHeadTime.setText(FRString.valueOf(data.getHead_time()));
        tvTitle.setText(FRString.valueOf(data.getHead()));
        tvTime.setText(FRString.valueOf(data.getCreate_time()));
        tvContent.setText(FRString.valueOf(data.getContent()));
        if (!FRString.isEmpty(data.getImg_url())) {
            ivImage.setVisibility(View.VISIBLE);
            FRImageLoad.loadImage(data.getImg_url(), ivImage,R.drawable.icon_message_default);
        }
    }
}